actionSearch = function() {
	var strKeyword = $.trim($('#keyword').val());
	if(strKeyword == '') {
		alert(name_required);
		return false;
	} else if(strKeyword != '' && strKeyword.length < 3) {
		alert(name_minlength);
		return false;
	}
	return true;
}
actionSearchAdv = function() {
	var strKeyword 		= $.trim($('#keyword').val());
	var intAfrom		= $('#afrom').val();
	var intAto			= $('#ato').val();
	var intMarial		= $("input[name='marital[]']:checked:enabled").length;
	var intLgender		= $('#look_gender').val();
	var intOccupation	= $("input[name='occupation[]']:checked:enabled").length;
	var intAvatar		= $('#avatar').val();
	var intReligion		= $("input[name='religion[]']:checked:enabled").length;
	var intProvince		= $("input[name='province[]']:checked:enabled").length;
	var intPreference	= $("input[name='preference[]']:checked:enabled").length;		
	if(strKeyword == '' && intAfrom == 0 && intAto == 0 && intMarial == 0 && intLgender == 0 && intOccupation == 0 && intAvatar == 0 && intReligion == 0 && intProvince == 0 && intPreference == 0) {
		alert(name_adv_required);
		$('#keyword').focus();
		return false;
	} else if(strKeyword != '' && strKeyword.length < 3) {
		alert(name_minlength);
		$('#keyword').focus();
		return false;
	}
	return true;
}
$(document).ready(function() {	
	$.cookie('AUTOLOAD_MEMBER', 1);
	$(window).scroll(function(){			
		if($(window).scrollTop() == $(document).height() - $(window).height()){
			intAdv = $('#advance').val();
			if(intAdv == 0)
				loadSearch();
			else
				loadSearchAdv();
		}
	}); 
});
function loadSearch() {	
	var intPage 	= $('#ppage').val();
	var strUserId	= $('#puserid').val();
	var strKeyword	= $('#keyword').val();
	if($.cookie('AUTOLOAD_MEMBER') == 1 && intPage > 0 && strKeyword != '') {		
		$.cookie('AUTOLOAD_MEMBER',0);	
		$('.boxResult .loading').show();
		$.getJSON(				
			HOST_VFRIEND + 'ajax/member?act=2&advance=0&page='+intPage+'&uid='+strUserId+'&keyword='+encodeURIComponent(strKeyword)+'&callback=?',		
			function(response) {	
				var msg 	= response['msg'];
				var error	= response['error'];
				if(error == 0) {
					$('#ppage').remove();
					$('.boxResult .loading').hide();					
					$('.boxResult #data').append(response['dmember']);
				} else {
					alert(msg);
				}
				$.cookie('AUTOLOAD_MEMBER', 1);
			}
		);
	}
}
function loadSearchAdv() {	
	var intPage 	= $('#ppage').val();
	var strUserId	= $('#puserid').val();
	if($.cookie('AUTOLOAD_MEMBER') == 1 && intPage > 0) {		
		$.cookie('AUTOLOAD_MEMBER',0);	
		$('.boxResult .loading').show();		
		var strKeyword	= $('#keyword').val();   
		var intAfrom	= $('#afrom').val();
		var intAto		= $('#ato').val(); 
		var intLgender	= $('#look_gender').val();  
		var intAvatar 	= $('#avatar').val();		
		var arrMarital  	= new Array();
		var arrOccupation  	= new Array();	
		var arrReligion  	= new Array();
		var arrProvince  	= new Array();	
		var arrPreference  	= new Array();	
		$("input[name='marital[]']:checked:enabled").each(function(){
			 arrMarital.push(this.value);
		});
		$("input[name='occupation[]']:checked:enabled").each(function(){
			 arrOccupation.push(this.value);
		});
		$("input[name='religion[]']:checked:enabled").each(function(){
			 arrReligion.push(this.value);
		});
		$("input[name='province[]']:checked:enabled").each(function(){
			 arrProvince.push(this.value);
		});
		$("input[name='preference[]']:checked:enabled").each(function(){
			 arrPreference.push(this.value);
		});
		$.getJSON(				
			HOST_VFRIEND + 'ajax/member?act=2&advance=1&page='+intPage+'&uid='+strUserId+'&keyword='+encodeURIComponent(strKeyword)+'&afrom='+intAfrom+'&ato='+intAto+'&gender='+intLgender+'&avatar='+intAvatar+'&marital='+arrMarital+'&occupation='+arrOccupation+'&religion='+arrReligion+'&province='+arrProvince+'&preference='+arrPreference+'&callback=?',		
			function(response) {	
				var msg 	= response['msg'];
				var error	= response['error'];
				if(error == 0) {
					$('#ppage').remove();
					$('.boxResult .loading').hide();					
					$('.boxResult #data').append(response['dmember']);
				} else {
					alert(msg);
				}
				$.cookie('AUTOLOAD_MEMBER', 1);
			}
		);
	}
}
onMouseOver = function(intId) {
	$('#member' + intId).show();
}
onMouseOut = function(intId) {
	$('#member' + intId).hide();
}